package Test;

import domain.Card;
import domain.Transaction;
import domain.User;
import utils.Tools;

import java.io.IOException;
import java.text.ParseException;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

public class ToolsTest {
    static Tools tools;
    public static void main(String[] args) throws IOException, ParseException {
        tools = new Tools();
/*
        User user = new User();
        user.setUserId("S00003");
        user.setName("Mike");
        user.setPassword("123321");
        user.setRole("admin");
        user.setPhone("1234567");
        user.setEmail("123@qq.com");

        testSetUser(user);
        testGetUser("S00003");

 */
/*
        Card card = new Card();
        card.setCardId("C00003");
        card.setUserId("S00003");
        card.setBalance(Double.parseDouble("19.9"));
        card.setStatus("正常");

        testSetCard(card);
        testGetCard("S00003");
*/

/*
        Transaction transaction = new Transaction();
        transaction.setTransactionId("T10011");
        transaction.setCardId("C10002");
        transaction.setType("recharge");
        transaction.setAmount(Double.parseDouble("9.9"));
        testSetTransaction(transaction);
        testGetTransaction("1");

 */

//        testRemoveUser("3");

//        testSetID("zs",2);
//        testGetID("userId");

//        testRemoveCard("1");
    }
    public static void testGetUser(String id) throws IOException {
        User user = tools.getUser(id);
        System.out.println(user);
    }

    public static void testSetUser(User user) throws IOException {
        tools.setUser(user);
    }

    public static void testGetCard(String id) throws IOException {
        Card card = tools.getCardByUserId(id);
        System.out.println(card);
    }

    public static void testSetCard(Card card) throws IOException {
        tools.setCard(card);
    }

    public static void testGetTransaction(String id) throws IOException, ParseException {
        List<Transaction> list = tools.getTransaction(id);
        for(Transaction s : list){
            System.out.println(s);
        }
    }

    public static void testSetTransaction(Transaction transaction) throws IOException {
        tools.setTransaction(transaction);
    }

    public static void testRemoveUser(String id) throws IOException {
        tools.removeUserById(id);
    }

    public static void testSetID(String name, int id) throws IOException {
        tools.setID(name,id);
    }

    public static void testGetID(String name) throws IOException {
        System.out.println(tools.getID(name));
    }

    public static void testRemoveCard(String id) throws IOException {
        tools.removeCardByUserId(id);
    }
}
